package SpaceIT.components;

import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;

import model.dao.DongSanPhamDAO;
import model.dao.NhaSanXuatDAO;
import model.pojo.DongSanPham;
import model.pojo.HangSanXuat;

import org.apache.tapestry5.*;
import org.apache.tapestry5.annotations.*;
import org.apache.tapestry5.ioc.*;
import org.apache.tapestry5.ioc.annotations.*;
import org.apache.tapestry5.services.Request;
import org.apache.tapestry5.services.Session;

import view.util.util;

import controller.util.ControllerHelper;

/**
 * Layout component for pages of application SpaceIT.
 */
public class menu_nav
{
	@Property
	@Parameter
	private util viewHelper;
	
	@Property
	private int i;
	
	@Property
	private int j;
	
	@Property
	@Parameter
	private int Op;

	@Property
	private ArrayList<HangSanXuat> arr2;//hang san xuat
	
	@Property
	private ArrayList<DongSanPham> arr3;//DongSanPham
		
	public boolean isLaptop(){
//	{
		if(Op == 1)
			return true;
		return false;
	}
	
	public int SoLuongNhaSanXuat(String TenLoaiSP){
//	{
		arr2 = NhaSanXuatDAO.HangSanXuatSanPham(TenLoaiSP);
		if(arr2 == null)
			return 0;
		return arr2.size();
	}
	
	public int SoLuongDongSanPhamTheoNSX(int LoaiSP , int MaHangSX){
//	{
		arr3 = DongSanPhamDAO.DongSanPhamTheoNSX(LoaiSP , MaHangSX);
		if(arr3 == null)
			return 0;
		return arr3.size();
	}
	
	public int SoLuongDongSanPham(int LoaiSP){
//	{
		arr3 = DongSanPhamDAO.DongSanPham(LoaiSP);
		if(arr3 == null)
			return 0;
		return arr3.size();
	}
	
	public String getTenNhaSanXuat(int i){
//	{
		return arr2.get(i).getTenHangSX();
	}
	
	public String getMaNhaSanXuat(int i){
//	{
		return arr2.get(i).getMaHangSX();
	}
	
	public String getTenDongSanPham(int i){
//	{
		return arr3.get(i).getMoTa();
	}
		
	public String getMaDongSanPham(int i){
//	{
		return String.valueOf(arr3.get(i).getMaDongSP());
	}
}
